public class L27 {

//    此题考察双指针

    public static int removeElement(int[] nums, int val) {
        int i = nums.length;
        for (int k = 0; k < i; ) {
            if (val == nums[k]) {
                nums[k] = nums[i - 1];
                i--;
            } else {
                k++;
            }
        }
        return i;
    }

    public static void main(String[] args) {
        int[] nums = {3, 2, 2, 3};
        int val = 3;

        int k = removeElement(nums, val);
        System.out.println(k);

    }
}
